#include <iostream>
#include <new>

//generate t-combination from a set {0..n-1}
void combination(int t, int n) {
	//init
	int * a= new int[t+2];
	int j;
	for (j = 0; j < t; j++)
		a[j]=j;
	a[t] = n;
	a[t+1] = 0;
	do {
		for (int i=0; i < t; i++)
			std::cout << a[i] << ' ';
		std::cout << std::endl;
		j = 0;
		while(a[j] + 1 == a[j+1]) {
			a[j] = j;
			j++;
		}
		a[j]++;
	}
	while(j<t);
	delete[] a;
}